.class public Les/r9;
.super Ljava/lang/Object;
.source "Mp4MoovCacheWriter.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Les/r9$a;
    }
.end annotation


# instance fields
.field private a:Ljava/io/File;

.field private b:Les/r9$a;

.field private c:Ljavax/xml/transform/sax/TransformerHandler;

.field private d:Z

.field private e:J

.field private f:J

.field private g:J


# direct methods
.method public constructor <init>(Ljava/lang/String;)V
    .locals 2

    .line 1
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    const/4 v0, 0x0

    .line 2
    iput-boolean v0, p0, Les/r9;->d:Z

    const-wide/16 v0, -0x1

    .line 3
    iput-wide v0, p0, Les/r9;->e:J

    .line 4
    new-instance v0, Ljava/io/File;

    invoke-static {p1}, Les/q9;->a(Ljava/lang/String;)Ljava/lang/String;

    move-result-object p1

    invoke-direct {v0, p1}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    iput-object v0, p0, Les/r9;->a:Ljava/io/File;

    .line 5
    invoke-virtual {v0}, Ljava/io/File;->getParent()Ljava/lang/String;

    move-result-object p1

    invoke-static {p1}, Lcom/esfile/screen/recorder/media/util/j;->a(Ljava/lang/String;)Z

    .line 6
    iget-object p1, p0, Les/r9;->a:Ljava/io/File;

    invoke-static {p1}, Les/r9$a;->a(Ljava/io/File;)Les/r9$a;

    move-result-object p1

    iput-object p1, p0, Les/r9;->b:Les/r9$a;

    if-eqz p1, :cond_0

    .line 7
    :try_start_0
    invoke-static {}, Ljavax/xml/transform/sax/SAXTransformerFactory;->newInstance()Ljavax/xml/transform/TransformerFactory;

    move-result-object p1

    check-cast p1, Ljavax/xml/transform/sax/SAXTransformerFactory;

    .line 8
    invoke-virtual {p1}, Ljavax/xml/transform/sax/SAXTransformerFactory;->newTransformerHandler()Ljavax/xml/transform/sax/TransformerHandler;

    move-result-object p1

    iput-object p1, p0, Les/r9;->c:Ljavax/xml/transform/sax/TransformerHandler;

    .line 9
    invoke-interface {p1}, Ljavax/xml/transform/sax/TransformerHandler;->getTransformer()Ljavax/xml/transform/Transformer;

    move-result-object p1

    const-string v0, "indent"

    const-string v1, "yes"

    .line 10
    invoke-virtual {p1, v0, v1}, Ljavax/xml/transform/Transformer;->setOutputProperty(Ljava/lang/String;Ljava/lang/String;)V

    const-string v0, "encoding"

    const-string v1, "UTF-8"

    .line 11
    invoke-virtual {p1, v0, v1}, Ljavax/xml/transform/Transformer;->setOutputProperty(Ljava/lang/String;Ljava/lang/String;)V

    .line 12
    new-instance p1, Ljavax/xml/transform/stream/StreamResult;

    iget-object v0, p0, Les/r9;->b:Les/r9$a;

    invoke-direct {p1, v0}, Ljavax/xml/transform/stream/StreamResult;-><init>(Ljava/io/Writer;)V

    .line 13
    iget-object v0, p0, Les/r9;->c:Ljavax/xml/transform/sax/TransformerHandler;

    invoke-interface {v0, p1}, Ljavax/xml/transform/sax/TransformerHandler;->setResult(Ljavax/xml/transform/Result;)V

    .line 14
    invoke-direct {p0}, Les/r9;->d()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    :catch_0
    :cond_0
    const-wide/16 v0, 0x0

    .line 15
    iput-wide v0, p0, Les/r9;->f:J

    .line 16
    iput-wide v0, p0, Les/r9;->g:J

    return-void
.end method

.method private static a(Ljava/nio/ByteBuffer;)Ljava/lang/String;
    .locals 4

    .line 41
    new-instance v0, Ljava/lang/StringBuilder;

    const-string v1, ""

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    .line 42
    invoke-virtual {p0}, Ljava/nio/ByteBuffer;->position()I

    move-result v1

    .line 43
    invoke-virtual {p0}, Ljava/nio/ByteBuffer;->limit()I

    move-result v2

    :goto_0
    if-ge v1, v2, :cond_0

    .line 44
    invoke-virtual {p0, v1}, Ljava/nio/ByteBuffer;->get(I)B

    move-result v3

    invoke-virtual {v0, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    const-string v3, ","

    invoke-virtual {v0, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    add-int/lit8 v1, v1, 0x1

    goto :goto_0

    .line 45
    :cond_0
    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p0

    return-object p0
.end method

.method private a(Ljava/lang/String;)V
    .locals 2

    const-string v0, ""

    .line 39
    :try_start_0
    iget-object v1, p0, Les/r9;->c:Ljavax/xml/transform/sax/TransformerHandler;

    if-eqz v1, :cond_0

    .line 40
    iget-object v1, p0, Les/r9;->c:Ljavax/xml/transform/sax/TransformerHandler;

    invoke-interface {v1, v0, v0, p1}, Ljavax/xml/transform/sax/TransformerHandler;->endElement(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
    :try_end_0
    .catch Lorg/xml/sax/SAXException; {:try_start_0 .. :try_end_0} :catch_0

    :catch_0
    :cond_0
    return-void
.end method

.method private a(Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)V
    .locals 1

    if-eqz p1, :cond_0

    const-string v0, "csd0"

    .line 33
    invoke-direct {p0, v0}, Les/r9;->c(Ljava/lang/String;)V

    .line 34
    invoke-static {p1}, Les/r9;->a(Ljava/nio/ByteBuffer;)Ljava/lang/String;

    move-result-object p1

    invoke-direct {p0, p1}, Les/r9;->b(Ljava/lang/String;)V

    .line 35
    invoke-direct {p0, v0}, Les/r9;->a(Ljava/lang/String;)V

    :cond_0
    if-eqz p2, :cond_1

    const-string p1, "csd1"

    .line 36
    invoke-direct {p0, p1}, Les/r9;->c(Ljava/lang/String;)V

    .line 37
    invoke-static {p2}, Les/r9;->a(Ljava/nio/ByteBuffer;)Ljava/lang/String;

    move-result-object p2

    invoke-direct {p0, p2}, Les/r9;->b(Ljava/lang/String;)V

    .line 38
    invoke-direct {p0, p1}, Les/r9;->a(Ljava/lang/String;)V

    :cond_1
    return-void
.end method

.method private b()V
    .locals 1

    .line 18
    :try_start_0
    iget-object v0, p0, Les/r9;->c:Ljavax/xml/transform/sax/TransformerHandler;

    if-eqz v0, :cond_0

    .line 19
    iget-object v0, p0, Les/r9;->c:Ljavax/xml/transform/sax/TransformerHandler;

    invoke-interface {v0}, Ljavax/xml/transform/sax/TransformerHandler;->endDocument()V
    :try_end_0
    .catch Lorg/xml/sax/SAXException; {:try_start_0 .. :try_end_0} :catch_0

    :catch_0
    :cond_0
    return-void
.end method

.method private b(Ljava/lang/String;)V
    .locals 3

    .line 15
    :try_start_0
    iget-object v0, p0, Les/r9;->c:Ljavax/xml/transform/sax/TransformerHandler;

    if-eqz v0, :cond_0

    .line 16
    invoke-virtual {p1}, Ljava/lang/String;->toCharArray()[C

    move-result-object p1

    .line 17
    iget-object v0, p0, Les/r9;->c:Ljavax/xml/transform/sax/TransformerHandler;

    const/4 v1, 0x0

    array-length v2, p1

    invoke-interface {v0, p1, v1, v2}, Ljavax/xml/transform/sax/TransformerHandler;->characters([CII)V
    :try_end_0
    .catch Lorg/xml/sax/SAXException; {:try_start_0 .. :try_end_0} :catch_0

    :catch_0
    :cond_0
    return-void
.end method

.method private c()V
    .locals 1

    .line 1
    :try_start_0
    iget-object v0, p0, Les/r9;->b:Les/r9$a;

    if-eqz v0, :cond_0

    .line 2
    iget-object v0, p0, Les/r9;->b:Les/r9$a;

    invoke-virtual {v0}, Ljava/io/BufferedWriter;->flush()V
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    :catch_0
    :cond_0
    return-void
.end method

.method private c(Ljava/lang/String;)V
    .locals 3

    const-string v0, ""

    .line 3
    :try_start_0
    iget-object v1, p0, Les/r9;->c:Ljavax/xml/transform/sax/TransformerHandler;

    if-eqz v1, :cond_0

    .line 4
    iget-object v1, p0, Les/r9;->c:Ljavax/xml/transform/sax/TransformerHandler;

    const/4 v2, 0x0

    invoke-interface {v1, v0, v0, p1, v2}, Ljavax/xml/transform/sax/TransformerHandler;->startElement(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lorg/xml/sax/Attributes;)V
    :try_end_0
    .catch Lorg/xml/sax/SAXException; {:try_start_0 .. :try_end_0} :catch_0

    :catch_0
    :cond_0
    return-void
.end method

.method private d()V
    .locals 1

    .line 1
    :try_start_0
    iget-object v0, p0, Les/r9;->c:Ljavax/xml/transform/sax/TransformerHandler;

    if-eqz v0, :cond_0

    .line 2
    iget-object v0, p0, Les/r9;->c:Ljavax/xml/transform/sax/TransformerHandler;

    invoke-interface {v0}, Ljavax/xml/transform/sax/TransformerHandler;->startDocument()V
    :try_end_0
    .catch Lorg/xml/sax/SAXException; {:try_start_0 .. :try_end_0} :catch_0

    :catch_0
    :cond_0
    return-void
.end method


# virtual methods
.method public a()V
    .locals 1

    .line 1
    iget-boolean v0, p0, Les/r9;->d:Z

    if-eqz v0, :cond_0

    const/4 v0, 0x0

    .line 2
    iput-boolean v0, p0, Les/r9;->d:Z

    const-string v0, "sample_table"

    .line 3
    invoke-direct {p0, v0}, Les/r9;->a(Ljava/lang/String;)V

    .line 4
    :cond_0
    invoke-direct {p0}, Les/r9;->b()V

    .line 5
    iget-object v0, p0, Les/r9;->b:Les/r9$a;

    if-eqz v0, :cond_1

    .line 6
    invoke-virtual {v0}, Les/r9$a;->close()V

    :cond_1
    return-void
.end method

.method public a(Landroid/media/MediaFormat;)V
    .locals 5

    if-eqz p1, :cond_0

    const-string v0, "audio"

    .line 7
    invoke-direct {p0, v0}, Les/r9;->c(Ljava/lang/String;)V

    const-string v1, "mime"

    .line 8
    invoke-direct {p0, v1}, Les/r9;->c(Ljava/lang/String;)V

    .line 9
    invoke-virtual {p1, v1}, Landroid/media/MediaFormat;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-direct {p0, v2}, Les/r9;->b(Ljava/lang/String;)V

    .line 10
    invoke-direct {p0, v1}, Les/r9;->a(Ljava/lang/String;)V

    const-string v1, "sample_rate"

    .line 11
    invoke-direct {p0, v1}, Les/r9;->c(Ljava/lang/String;)V

    .line 12
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, ""

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    const-string v4, "sample-rate"

    invoke-virtual {p1, v4}, Landroid/media/MediaFormat;->getInteger(Ljava/lang/String;)I

    move-result v4

    invoke-virtual {v2, v4}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-direct {p0, v2}, Les/r9;->b(Ljava/lang/String;)V

    .line 13
    invoke-direct {p0, v1}, Les/r9;->a(Ljava/lang/String;)V

    const-string v1, "channel_count"

    .line 14
    invoke-direct {p0, v1}, Les/r9;->c(Ljava/lang/String;)V

    .line 15
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    const-string v3, "channel-count"

    invoke-virtual {p1, v3}, Landroid/media/MediaFormat;->getInteger(Ljava/lang/String;)I

    move-result v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-direct {p0, v2}, Les/r9;->b(Ljava/lang/String;)V

    .line 16
    invoke-direct {p0, v1}, Les/r9;->a(Ljava/lang/String;)V

    const-string v1, "csd-0"

    .line 17
    invoke-static {p1, v1}, Lcom/esfile/screen/recorder/media/util/s;->a(Landroid/media/MediaFormat;Ljava/lang/String;)Ljava/nio/ByteBuffer;

    move-result-object v1

    const-string v2, "csd-1"

    .line 18
    invoke-static {p1, v2}, Lcom/esfile/screen/recorder/media/util/s;->a(Landroid/media/MediaFormat;Ljava/lang/String;)Ljava/nio/ByteBuffer;

    move-result-object p1

    .line 19
    invoke-direct {p0, v1, p1}, Les/r9;->a(Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)V

    .line 20
    invoke-direct {p0, v0}, Les/r9;->a(Ljava/lang/String;)V

    :cond_0
    return-void
.end method

.method public a(ZLandroid/media/MediaCodec$BufferInfo;)V
    .locals 6
    .param p2    # Landroid/media/MediaCodec$BufferInfo;
        .annotation build Landroidx/annotation/NonNull;
        .end annotation
    .end param

    .line 21
    iget-boolean v0, p0, Les/r9;->d:Z

    const/4 v1, 0x1

    if-nez v0, :cond_0

    .line 22
    iput-boolean v1, p0, Les/r9;->d:Z

    const-string v0, "sample_table"

    .line 23
    invoke-direct {p0, v0}, Les/r9;->c(Ljava/lang/String;)V

    .line 24
    :cond_0
    iget-wide v2, p2, Landroid/media/MediaCodec$BufferInfo;->presentationTimeUs:J

    iget-wide v4, p0, Les/r9;->e:J

    sub-long/2addr v2, v4

    const-wide/32 v4, 0x4c4b40

    cmp-long v0, v2, v4

    if-lez v0, :cond_1

    .line 25
    invoke-direct {p0}, Les/r9;->c()V

    .line 26
    iget-wide v2, p2, Landroid/media/MediaCodec$BufferInfo;->presentationTimeUs:J

    iput-wide v2, p0, Les/r9;->e:J

    :cond_1
    if-eqz p1, :cond_2

    .line 27
    iget-wide v2, p2, Landroid/media/MediaCodec$BufferInfo;->presentationTimeUs:J

    iget-wide v4, p0, Les/r9;->f:J

    sub-long v4, v2, v4

    .line 28
    iput-wide v2, p0, Les/r9;->f:J

    goto :goto_0

    .line 29
    :cond_2
    iget-wide v2, p2, Landroid/media/MediaCodec$BufferInfo;->presentationTimeUs:J

    iget-wide v4, p0, Les/r9;->g:J

    sub-long v4, v2, v4

    .line 30
    iput-wide v2, p0, Les/r9;->g:J

    .line 31
    :goto_0
    iget v0, p2, Landroid/media/MediaCodec$BufferInfo;->flags:I

    and-int/2addr v0, v1

    if-eqz v0, :cond_3

    goto :goto_1

    :cond_3
    const/4 v1, 0x0

    .line 32
    :goto_1
    new-instance v0, Ljava/lang/StringBuilder;

    invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    const-string p1, ","

    invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    iget p2, p2, Landroid/media/MediaCodec$BufferInfo;->size:I

    invoke-virtual {v0, p2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v0, v4, v5}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder;

    if-eqz v1, :cond_4

    const-string p1, ",1"

    goto :goto_2

    :cond_4
    const-string p1, ""

    :goto_2
    invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    const-string p1, ";"

    invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p1

    invoke-direct {p0, p1}, Les/r9;->b(Ljava/lang/String;)V

    return-void
.end method

.method public b(Landroid/media/MediaFormat;)V
    .locals 5

    if-eqz p1, :cond_0

    const-string v0, "video"

    .line 1
    invoke-direct {p0, v0}, Les/r9;->c(Ljava/lang/String;)V

    const-string v1, "mime"

    .line 2
    invoke-direct {p0, v1}, Les/r9;->c(Ljava/lang/String;)V

    .line 3
    invoke-virtual {p1, v1}, Landroid/media/MediaFormat;->getString(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-direct {p0, v2}, Les/r9;->b(Ljava/lang/String;)V

    .line 4
    invoke-direct {p0, v1}, Les/r9;->a(Ljava/lang/String;)V

    const-string v1, "width"

    .line 5
    invoke-direct {p0, v1}, Les/r9;->c(Ljava/lang/String;)V

    .line 6
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v3, ""

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {p1, v1}, Landroid/media/MediaFormat;->getInteger(Ljava/lang/String;)I

    move-result v4

    invoke-virtual {v2, v4}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-direct {p0, v2}, Les/r9;->b(Ljava/lang/String;)V

    .line 7
    invoke-direct {p0, v1}, Les/r9;->a(Ljava/lang/String;)V

    const-string v1, "height"

    .line 8
    invoke-direct {p0, v1}, Les/r9;->c(Ljava/lang/String;)V

    .line 9
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {p1, v1}, Landroid/media/MediaFormat;->getInteger(Ljava/lang/String;)I

    move-result v3

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-direct {p0, v2}, Les/r9;->b(Ljava/lang/String;)V

    .line 10
    invoke-direct {p0, v1}, Les/r9;->a(Ljava/lang/String;)V

    const-string v1, "csd-0"

    .line 11
    invoke-static {p1, v1}, Lcom/esfile/screen/recorder/media/util/s;->a(Landroid/media/MediaFormat;Ljava/lang/String;)Ljava/nio/ByteBuffer;

    move-result-object v1

    const-string v2, "csd-1"

    .line 12
    invoke-static {p1, v2}, Lcom/esfile/screen/recorder/media/util/s;->a(Landroid/media/MediaFormat;Ljava/lang/String;)Ljava/nio/ByteBuffer;

    move-result-object p1

    .line 13
    invoke-direct {p0, v1, p1}, Les/r9;->a(Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)V

    .line 14
    invoke-direct {p0, v0}, Les/r9;->a(Ljava/lang/String;)V

    :cond_0
    return-void
.end method
